package com.hu.zhcc.shiro.service.dingming;

import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.common.entity.PageRequest;
import com.hu.zhcc.shiro.dao.dingming.TMealsMapper;
import com.hu.zhcc.shiro.entity.dingming.TMeals;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TMealsServiceImpl implements TMealsService{
    @Autowired
    private TMealsMapper tMealsMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return tMealsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(TMeals record) {
        return tMealsMapper.insert(record);
    }

    @Override
    public int insertSelective(TMeals record) {
        return tMealsMapper.insertSelective(record);
    }

    @Override
    public TMeals selectByPrimaryKey(Integer id) {
        return tMealsMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(TMeals record) {
        return tMealsMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(TMeals record) {
        return tMealsMapper.updateByPrimaryKey(record);
    }

    @Override
    public Page<TMeals> listTMeals(Map<String, Object> parameters, int offset, int limit) {
        int total = tMealsMapper.countTMeals(parameters);
        List<TMeals>  tMeals= null;
        if (total > 0) {
            PageRequest pageRequest = new PageRequest(offset, limit, parameters);
            tMeals = tMealsMapper.listTMeals(pageRequest);
        }
        return new Page<TMeals>(total, tMeals);
    }
}
